package com.sc.nft.req.wxPay;

import cn.hutool.core.collection.ListUtil;
import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * 发起商家转账请求参数
 *
 * @Author：LiGen
 * @Package：com.metago.mallmini.domain.req.pay
 * @Project：meta_mall_mini_app
 * @name：BatchTransferReq
 * @Date：2024/5/11 11:21
 * @Filename：BatchTransferReq
 */
@Data
public class BatchTransferReq {

    @ApiModelProperty("商家批次单号 商户系统内部的商家批次单号，要求此参数只能由数字、大小写字母组成，在商户系统内部唯一")
    private String outBatchNo;

    @ApiModelProperty("批次名称 该笔批量转账的名称")
    private String batchName;

    @ApiModelProperty("批次备注 转账说明，UTF8编码，最多允许32个字符")
    private String batchRemark;

    @ApiModelProperty("转账总笔数 说明：一个转账批次单最多发起一千笔转账。转账总笔数必须与批次内所有明细之和保持一致，否则无法发起转账操作")
    private Integer totalNum;

    @ApiModelProperty("转账明细列表 发起批量转账的明细列表，最多一千笔")
    private List<TransferDetail> transferDetails;

    public static BatchTransferReq buildOne(String outBatchNo, String batchRemark, String outDetailNo, BigDecimal transferAmount, String openId, String userName) {
        BatchTransferReq batchTransferReq = new BatchTransferReq();
        batchTransferReq.setOutBatchNo(outBatchNo);
        batchTransferReq.setBatchName(outBatchNo + "转账");
        batchTransferReq.setTotalNum(1);
        batchTransferReq.setBatchRemark(batchRemark);
        // 转账明细
        TransferDetail transferDetail = new TransferDetail();
        transferDetail.setOutDetailNo(outDetailNo);
        transferDetail.setTransferAmount(transferAmount.multiply(new BigDecimal(100)).setScale(0).longValue());
        transferDetail.setTransferRemark(batchRemark);
        transferDetail.setOpenid(openId);
        transferDetail.setUserName(userName);
        batchTransferReq.setTransferDetails(ListUtil.of(transferDetail));
        return batchTransferReq;
    }

}
